var htmlWebpackPlugin = require('html-webpack-plugin')
const webpack = require('webpack');
var path = require('path')
module.exports = {
    //context: __dirname,
    //context:''
    //entry:'./src/js/cart.js',
    //entry:['./src/js/cart.js','./src/js/lib/vue-resource.min.js'],
    //	entry:{
    //		"main":'./src/js/cart.js',
    //		"resource":'./src/js/lib/vue-resource.min.js'
    //	},
    /* 多页面
    entry: {
    	"main": './src/js/cart.js',
    	"resource": './src/js/lib/resource.js',
    	"vue": './src/js/lib/vue2.js',
    	"address": './src/js/address.js'
    }, */
    entry: './src/app.js',
    output: {
        path: './dist/',
        filename: 'js/[name].bundle.js',
        //publicPath: 'http://cdn.com'
    },
    module: {
        loaders: [{
                test: /\.js$/,
                //exclude: /node_modules/,
                exclude: path.resolve(__dirname, ' node_modules'),
                loader: 'babel',
                include: path.resolve(__dirname, ' src'),
                query: {
                    presets: ['latest']
                }
            },
            {
                test: /\.css$/,
                loader: 'style-loader!css-loader!postcss-loader',
                //loaders: ['style-loader','css-loader','postcss-loader']
            },
						{
							test:/\.less$/,
							loader:'style-loader!css-loader!postcss-loader!less-loader'
						 },
						{
							test:/\.html$/,
							loader:'html-loader'
						},
						{
							test:/\.tpl$/,
							loader:'ejs-loader'
						},
						{
							test:/\.scss$/,
							loader:'style-loader!css-loader!postcss-loader!sass-loader'
						},
						{
							test:/\.(png|jpg|gif|svg)$/i,
							//loader:'url-loader',
							loaders:['url-loader?limit=20000&name=assset/[name]-[hash:5].[ext]','image-webpack-loader']
							// query:{
							// 	limit:50000,
							// 	name:'assset/[name]-[hash:5].[ext]'
							// }
						},
        ]
    },
    plugins: [
        new webpack.LoaderOptionsPlugin({
            options: {
                postcss: [require('autoprefixer')({
                    broswers: ['last 5 versions']
                })],
            }
        }),
        new htmlWebpackPlugin({
            filename: 'index.html',
            template: 'index.html',

        })


        /* 多页面
        new webpack.optimize.UglifyJsPlugin(),
           new htmlWebpackPlugin({
        		title: 'main',
        		filename: 'main.html',
        		//	filename:'index-[hash].html',
        		//inject:'head',
        		inject: 'body',
        		template: 'index.html',
        		chunks: ["address","main","resource","vue"],
        			//date: new Date(),
        		minify:{
        			//清除注释
        			//removeComments:true,
        			//去除空格，相当于压缩html
        			collapseWhitespace:true
        			}
        		}),
        	new htmlWebpackPlugin({
        		title: 'resource',
        		filename: 'resource.html',
        		//	filename:'index-[hash].html',
        		//inject:'head',
        		inject: 'body',
        		template: 'index.html',
        		data: ["vue","main"]
        			//date: new Date(),
        			//			minify:{
        			//				//清除注释
        			//				removeComments:true,
        			//				//去除空格，相当于压缩html
        			//				collapseWhitespace:true
        			//			}
        		}),
        		new htmlWebpackPlugin({
        		title: 'vue',
        		filename: 'vue.html',
        		//	filename:'index-[hash].html',
        		//inject:'head',
        		inject: false,
        		template: 'index.html',
        		chunks: ["resource","main","vue"]
        			//date: new Date(),
        			//			minify:{
        			//				//清除注释
        			//				removeComments:true,
        			//				//去除空格，相当于压缩html
        			//				collapseWhitespace:true
        			//			}
        		}),	*/

    ]
}
